﻿using System;
using Mesuro.Common;
using System.ComponentModel;

namespace Mesuro.Graphing.Utilities {
	public class SmithTransformedSeries : IterativeSeriesTransform {
		private static string[] admittanceChannels = { "Conductance", "Susceptance" };
		private static string[] impedanceChannels = { "Resistance", "Inductance" };
		private bool admittance;

		public SmithTransformedSeries( bool admittance = false ) {
			this.admittance = admittance;
		}

		public override Vector Transform( Vector source, object context ) {
			Vector ret = new Vector( 2 );
			if (admittance) {
				Complex Y = (Complex)source.Top( 2 );
				Y = ((1 - Y) / (1 + Y));
				ret[0] = Y.Re;
				ret[1] = Y.Im;
				return ret;
			} else {
				Complex Z = (Complex)source.Top( 2 );
				Z = ((Z - 1) / (Z + 1));
				ret[0] = Z.Re;
				ret[1] = Z.Im;
				return ret;
			}
		}
	}
}
